<?php
class ConfigDB {
	
	# varialble
	private $dbhost;
	private $dbuser;
	private $dbpass;
	private $dbname;
	
	public function __construct() {
		$this->dbhost = LOCALHOST;
		$this->dbuser = USERNAME;
		$this->dbpass = PASSWORD;
		$this->dbname = DATABASE;
	}
	
	public function dbconnect() {
		$db_connect = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass) or die (mysql_error());
		$db_select  = mysql_select_db($this->dbname, $db_connect) or die (mysql_error());
	}
	
	public function selectDB($query) {
		$this->dbconnect();
		$dline = 0;
		$result = mysql_query($query) or die (mysql_error());
		while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
			foreach ($line as $col_name => $col_value) {
				$alldata[$dline][$col_name] = $col_value;
			}
			$dline = $dline + 1;
		}
		mysql_free_result($result);
		return($alldata);
	}
	
	public function selectDB2($query) {
		$this->dbconnect();
		$result = mysql_query($query) or die (mysql_error());
		$result = mysql_query($query) or die (mysql_error());
		while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
			foreach ($line as $col_name => $col_value) {
				$onedata[$col_name] = $col_value;
			}
		}
		mysql_free_result($result);
		
		return($onedata);
	}
	
	public function queryDB($query) {
		$this->dbconnect();
		$result = mysql_query($query) or die (mysql_error());
	}
	
} // END Class
?>